using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using DataTransferObject;
using DataAccess;

namespace DataAccess
{
    public class clsBangCapDAO:clsDataAccessHelper 
    {
         // Fields
        private String tenTable;

        // Contructors
        public clsBangCapDAO()
        {
            this.tenTable = "BANGCAP";
        }
        #region Methods
        //-------------------------------------Lấy dữ liệu bảng Bộ Phận-----------------------

        public DataTable SelectAll()
        {
            String sql;
            DataTable dt;
            try
            {
                sql = "SELECT * FROM " + this.tenTable;
                dt = new DataTable();
                dt = this.ExecuteQuery(sql);

                return dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
       //-----------------------------------------------------------------------------//


        //-------------------------------------Thêm vào Bằng Cấp-----------------------

       public bool Insert(clsBangCapDTO bangcap)
       {
           String sql;
           bool check = false;

           try
           {
               sql = "INSERT INTO " + this.tenTable;
               sql += " values('";
               sql += bangcap .MaBC + "',N'";
               sql += bangcap .TenBC + "')";
               check = this.ExecuteNonQuery(sql);

               return check;
           }
           catch
           {
               return check;
           }
       }

        //-----------------------------------------------------------------------------//



       //-------------------------------------Xóa vào Bằng Cấp-----------------------
       public bool Delete(clsBangCapDTO bangcap)
       {
           String sql;
           bool check = false;

           try
           {
               sql = "DELETE ";
               sql += " FROM " + this.tenTable;
               sql += " WHERE MABC LIKE '" +bangcap .MaBC + "'";
               check = this.ExecuteNonQuery(sql);

               return check;
           }
           catch
           {
               return check;
           }
       }
       
       //-------------------------------------Sửa vào Bằng Cấp-----------------------

       public bool Update(clsBangCapDTO bangcap)
       {
           String sql;
           bool check = false;

           try
           {
               sql = "UPDATE " + this.tenTable;
               sql += " SET";
               sql += " TENBC = N'";
               sql += bangcap .TenBC + "'";
               sql += " WHERE MABC LIKE '";
               sql += bangcap .MaBC + "'";
               check = this.ExecuteNonQuery(sql);

               return check;
           }
           catch
           {
               return check;
           }
       }
       #endregion        
    }
}
